import tkiTree from '@/components/tki-tree/tki-tree1.vue';
	import safeData from '@/components/fieldSampling/safeList';

	import {
		log
	} from 'util'

	export default {

		data() {
			return {
				Inv: 3,
				// 列表
				unSubmitData: [], //列表数据
				datasList: {
					fCompanyid: "", // 左侧选中组织机构id
					userId: "", // 查询待办或已办时传 列表页查询不传
					fSamplemodel: "", // 上方查询条件样品种类  对应code
					fSamplename: "", // 上方查询条件样品名称
					fStatus: "", // 上方查询条件样品状态
					startDates: "", //取样日期开始时间
					endDates: "", //取样日期结束时间
					modelType: "3", // 取样：0-待办 1-已办;收样：3-待办 4-已办；查看：传2
					page: 1, // 当前页码
					pageSize: 20, // 每页显示条数
				}, //列表参数
			
				// 列表
				userInfo: null,
			}
		},
		components: {
			safeData,
			tkiTree,
		},
		onShow() {
			var that = this
			if (that.Inv == 3) {
				setTimeout(() => {
					that.unsubmit()

				}, 300)
			}
			if (that.Inv == 4) {
				setTimeout(() => {
					that.submit()
				}, 300)
			}
		},
		onLoad(option) {
			var that = this;
			uni.getStorage({ //监督检查方式
				key: 'userInfo',
				success: function(res) {
					if (option.Inv) {
						that.Inv = option.Inv
					}
					that.userInfo = JSON.parse(res.data);
					that.getListData();
				}
			});
		},
		onBackPress(event) {
			uni.switchTab({
				url: '/pages/home/index'
			});
			return true;
		},
		methods: {
			// 待办
			unsubmit() {
				var that = this
				this.Inv = 3;
				this.unSubmitData = [];
				this.getListData();
			},
			// 已办
			submit() {
				var that = this
				this.Inv = 4;
				this.unSubmitData = [];
				this.getListData();
			},
			// 跳详情页
			safeDetail(e) {
				if (e.Inv == 3) {
					uni.navigateTo({
						url: "/pages/apply/sampleManage/collection/inter/index?id=" + e.id
					});
					return false;
				} else if (e.Inv == 4) {
					uni.navigateTo({
						url: "/pages/apply/sampleManage/collection/submit/index?id=" + e.id
					});
					return false;
				}
			},
			// 列表
			getListData() {
				var that = this;
				let obj = {
					fCompanyid: that.userInfo.companyId, // 左侧选中组织机构id
					userId: that.userInfo.userId, // 查询待办或已办时传 列表页查询不传
					fSamplemodel: "", // 上方查询条件样品种类  对应code
					fSamplename: "", // 上方查询条件样品名称
					fStatus: "", // 上方查询条件样品状态
					startDates: "", //取样日期开始时间
					endDates: "", //取样日期结束时间
					modelType: that.Inv.toString(), // 取样：0-待办 1-已办;收样：3-待办 4-已办；查看：传2
					page:1, // 当前页码
					pageSize:20, // 每页显示条数
				}

				this.$http.getSampleWorkWebList(obj).then(res => {
					if (res.errcode == 0) {
						that.unSubmitData =res.data.pageInfo.list;
					} else {
						uni.showToast({
							title: "获取数据失败",
							icon: 'none',
							duration: 2000
						});
					}
				}, (err) => {
					uni.showToast({
						title: "获取数据失败",
						icon: 'none',
						duration: 2000
					});

				});
			},

		}
	}